/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.chiefmedicalofficer.mcd;

import org.chiefmedicalofficer.mcd.model.PropertyDescription;
import org.chiefmedicalofficer.mcd.model.PageDescription;
import org.chiefmedicalofficer.mcd.model.PredicateDescription;
import com.hp.hpl.jena.vocabulary.RDFS;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.chiefmedicalofficer.mcd.model.GraphStore;

/**
 *
 * @author twilson
 */
public class HelloMcd {

    static Logger log = Logger.getLogger(HelloMcd.class);
    static String mcdUri = "http://www.chiefmedicalofficer.org/ontologies/2010/0/mcd";

    public static void main(String[] args) {
        log.setLevel(Level.DEBUG);
        GraphStore gs = GraphStore.getInstance();
        String vocabularyUrl = "file:/home/twilson/ontologies/mcd/mcd.owl";
        String base = mcdUri;
        gs.loadVocabulary(vocabularyUrl, base);
        gs.addResourceTriple("http://foo", base + "#practicesAt", "http://bar");
        List<String> classList = gs.inferClass("http://foo");
        if (classList != null) {
            for (String c : classList) {
                log.debug("class foo is a " + c);
            }
        }
        classList = gs.inferClass("http://bar");
        if (classList != null) {
            for (String c : classList) {
                log.debug("class bar is a " + c);
            }
        }
    }

    private void testPageProperties() {
        log.setLevel(Level.DEBUG);

        PageDescription newPage = new PageDescription();
        newPage.setPageUri("http://www.nerdpod.org");
        newPage.setTitle("NerdPod.org Home Page");
        newPage.setLabel("my first semantic web page");
        PropertyDescription prop1 = new PropertyDescription();
        PredicateDescription pred1 = new PredicateDescription();
        pred1.setUri(RDFS.isDefinedBy.getURI());
        prop1.setSubjectUri(newPage.getPageUri());
        prop1.setPredicate(pred1);
        prop1.setObjectUri("http://www.nerdpod.org/definition");
        prop1.setPredicate(pred1);
        newPage.addObjectProperty(prop1);


        newPage.persist();
        newPage.setTitle("Second Title");
        newPage.persist();
        newPage.persist();



        PageDescription thePage = new PageDescription("http://www.nerdpod.org");

        log.debug("Page URI = " + thePage.getPageUri());
        log.debug("Title = " + thePage.getTitle());
        log.debug("Label = " + thePage.getLabel());
        log.debug(thePage.getRdfDescription());
        if (thePage.getObjectProperties() != null) {
            for (PropertyDescription prop : thePage.getObjectProperties()) {
                log.debug("Found property " + prop.getObjectUri());
                log.debug("Predicate " + prop.getPredicate().getUri());
                log.debug("With title " + prop.getObjectTitle());
                log.debug("------------");
            }
        }
        GraphStore gs = GraphStore.getInstance();
        log.debug(gs.getDataModel());

    }
}
